#include "safe.h"
#include "ui_safe.h"
#include"qdialoglogin.h"

#include<QMovie>
#include<QPixmap>

safe::safe(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::safe)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);//无边框但在任务栏上显示标题
    //qt实现动图播放
        QMovie *movie=new QMovie("C:/Qt/PROJECT_LEE/images/safetip.gif");
      //  QMovie *movie=new QMovie(":/../PROJECT_LEE/images/safetip.gif");  //资源
        ui->label_2->setMovie(movie);
        movie->start();

}

safe::~safe()
{
    delete ui;
}

void safe::mousePressEvent(QMouseEvent *event)
{
    //event->globalPos()获取鼠标以电脑屏幕左上角为原点的向量
    if(event->button()==Qt::LeftButton)
    {
        this->m_moveing2=true;
        m_lastPos=event->globalPos()-pos();//使用向量的减法获得鼠标相对于窗口的位置

    }
    return  QWidget::mousePressEvent(event);

}

void safe::mouseMoveEvent(QMouseEvent *event)
{
    //在mouseMoveEvent 里event->button()返回的引进事件的button永远是Qt::NoButton!!
    if(m_moveing2 && (event->buttons()&&Qt::LeftButton))//左键被按下
    {
        move(event->globalPos()-m_lastPos);
       //m_lastPos=event->globalPos()-pos();//使用向量的减法获得鼠标相对于窗口的位置
    }
   return QWidget::mouseMoveEvent(event);
}

void safe::mouseReleaseEvent(QMouseEvent *event)
{
   Q_UNUSED(event);
   m_moveing2=false;
}


void safe::on_pushButton_clicked()
{
    this->hide();
    QDialogLogin *QD=new QDialogLogin;
    QD->show();
}
